<?php
require_once '../auth.php';
require_once '../forward.php';
$user = $_SESSION['user'];

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $settings = $default_settings;
    foreach ($_POST as $key => $value) if (isset($settings[$key])) {
        $settings[$key] = ($value == 'on' ? 1 : 0);
    }
    save_settings($user, $settings);
} else {
    $settings = load_settings($user);
}

render_begin(' :: settings');
render_profile($user);
render_page_begin();
render_header();
?>
<div id="settings">
<form method="POST">
<input type="checkbox" name="default_public"<?php if ($settings['default_public']) echo ' checked'; ?>/>Create notes <i>public</i> by default (you still can toggle the checkbox before creating one).<br/>
<br/>
<input type="submit" value="Save"/>
</form>
</div>
<?php
render_footer();
render_page_end();
render_end();
?>
